package com.jeasonzhao.commons.data;

public class Table<CELL extends Cell> implements java.io.Serializable
{
    private static final long serialVersionUID = 1L;
    private RowCollection<CELL> header = new RowCollection<CELL>();
    private RowCollection<CELL> body = new RowCollection<CELL>();
    private RowCollection<CELL> footer = new RowCollection<CELL>();
    public Table()
    {
        super();
    }

    public RowCollection<CELL> getBody()
    {
        return body;
    }

    public RowCollection<CELL> getFooter()
    {
        return footer;
    }

    public RowCollection<CELL> getHeader()
    {
        return header;
    }

    public Table<CELL> setBody(RowCollection<CELL> body)
    {
        this.body = body;
        return this;
    }

    public Table<CELL> setFooter(RowCollection<CELL> footer)
    {
        this.footer = footer;
        return this;
    }

    public Table<CELL> setHeader(RowCollection<CELL> header)
    {
        this.header = header;
        return this;
    }

    public void alignDatas()
    {
        if(null!=this.header)
        {
            for(Row<CELL> r : this.header)
            {
                r.setRowType(RowTypes.Header);
            }
        }
        if(null!=this.footer)
        {
            for(Row<CELL> r : this.footer)
            {
                r.setRowType(RowTypes.Footer);
            }
        }
        if(null!=this.body)
        {
            for(Row<CELL> r : this.body)
            {
                r.setRowType(RowTypes.Body);
            }
        }
    }
}
